package com.grapecc.springcloud.controller;

import com.grapecc.springcloud.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 卖糖的兜兜
 * @version 1.0.0
 * @ClassName PaymentController.java
 * @Description TODO
 * @createTime 2022年02月12日 23:47:00
 */
@RestController
@Slf4j
@RequestMapping("/payment")
public class PaymentController {

    @Autowired
    private PaymentService payService;

    @Value("${server.port}")
    private String prot;

    @GetMapping("/hystrix/ok/{id}")
    public  String payment_oK(@PathVariable("id") Integer id){
        String s = payService.payment_oK(id);
        log.info("result:"+s);
        return s;
    }
    @GetMapping("/hystrix/timeout/{id}")
    public  String payment_timeout(@PathVariable("id") Integer id){
        String s = payService.payment_timeout(id);
        return s;
    }

    @GetMapping("/hystrix/{id}")
    public String Test(@PathVariable("id") Integer id){
       return payService.paymentCircuitBreaker(id);
    }

    /**
     *
     * @param id
     * @return
     */
    @GetMapping("/lib/{id}")
    public  String getProt(@PathVariable(value = "id") String id){
        return prot;
    }
}
